﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title></title>
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/MobileCom.js?20150725"></script>
    <script >
        $(function () {

            var appid = "wxf285796b249c0cf6";
            var funcode = MobileCom.getQueryString("funcode");
            var code = MobileCom.getQueryString("code");
            var state = MobileCom.getQueryString("state");

            if (MobileCom.getCookie("szhlcode")) {  //缓存的用户名，直接跳到对应的地址

                window.location = getRURL(funcode);

            }
            else {   //获取授权

                if (code) {   //授权回来，抓取用户名
                    var el = $.loading({
                        content: '加载中...',
                    })
                    $.getJSON("/API/WXAPI.ashx?action=GetUserCodeByCode", { "code": code }, function (r) {
                        el.loading("hide");
                        if (r.ErrorMsg == "") {
                            MobileCom.setCookie("szhlcode", r.Result, 7);
                            //MobileCom.setCookie("szhlusername", r.Result1, 7);
                            window.location = getRURL(state);
                        } else {
                            alert(r.ErrorMsg);
                        }

                    })


                } else { //微信企业号接口获取授权

                    var wx_r_url = encodeURIComponent("http://www.qijieyun.com/MobileView/UI/UI_COMMON.html");

                    var wxurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + wx_r_url + "&response_type=code&scope=snsapi_base&state=" + funcode + "#wechat_redirect";

                    window.location = wxurl;
                }

            }



        })



        function getRURL(funcode) {
            var rr_url = "http://www.qijieyun.com/MobileView/UI/";
            switch (funcode) {
                case "qygg": //企业公告
                    {
                        rr_url += "UI_QYGG_LIST.html?r=" + Math.random();
                    }
                    break;
                case "gzrba":  //工作日报添加
                    {
                        rr_url += "UI_GZRB_INPUT.html?r=" + Math.random();
                    }
                    break;
                case "gzrbb":  //工作日报列表
                    {
                        rr_url += "UI_GZRB_LIST.html?r=" + Math.random();
                    }
                    break;
                case "khgla":  //客户管理添加
                    {
                        rr_url += "UI_KHGL_INPUT.html?r=" + Math.random();
                    }
                    break;
                case "khglb":  //客户管理列表
                    {
                        rr_url += "UI_KHGL_LIST.html?r=" + Math.random();
                    }
                    break;
                case "hdbma":  //活动报名添加
                    {
                        rr_url += "UI_HDBM_INPUT.html?r=" + Math.random();
                    }
                    break;
                case "hdbmb":  //活动报名列表
                    {
                        rr_url += "UI_HDBM_LIST.html?r=" + Math.random();
                    }
                    break;
                case "qjcca":  //请假出差添加
                    {
                        rr_url += "UI_QJCC_INPUT.html?r=" + Math.random();
                    }
                    break;
                case "qjccb":  //请假出差列表
                    {
                        rr_url += "UI_QJCC_LIST.html?r=" + Math.random();
                    }
                    break;
                case "jfbxa":  //经费报销添加
                    {
                        rr_url += "UI_JFBX_BXMX.html?r=" + Math.random();
                    }
                    break;
                case "jfbxb":  //经费报销列表
                    {
                        rr_url += "UI_JFBX_LIST.html?r=" + Math.random();
                    }
                    break;
                case "dbsxa":  //任务待办添加
                    {
                        rr_url += "UI_DBSX_INPUT.html?r=" + Math.random();
                    }
                    break;
                case "dbsxb":  //任务待办列表
                    {
                        rr_url += "UI_DBSX_LIST.html?r=" + Math.random();
                    }
                    break;
                case "dbsxc":  //任务待办列表(部门)
                    {
                        rr_url += "UI_DBSX_DPLIST.html?r=" + Math.random();
                    }
                    break;
            }
            return rr_url;

        }
        

    </script>
</head>
<body>
   
</body>
</html>
